using System;
using System.ServiceProcess;

namespace ServiceFacade
{
    public class ServiceFacade : IServiceFacade
    {
        public void startService(string serviceName)
        {
            ServiceController service = new ServiceController(serviceName);

            if (service.Status == ServiceControllerStatus.Stopped)
                service.Start();
            else
                throw new ArgumentException("Cannot start a running service.");
        }

        public void stopService(string serviceName)
        {
            ServiceController service = new ServiceController(serviceName);

            if (service.Status == ServiceControllerStatus.Running)
                service.Stop();
            else
                throw new ArgumentException("Cannot stop a non-running service.");
        }
    }
}
